
//
//  TipsDetailsCollectionViewCell.m
//  Cooking
//
//  Created by ZhiPeng.Y on 15/8/26.
//  Copyright (c) 2015年 ZP.Y. All rights reserved.
//

#import "TipsDetailsCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "TipsDetailsModel.h"

@interface TipsDetailsCollectionViewCell ()

@property (retain, nonatomic) UIImageView *foodImage;
@property (retain, nonatomic) UILabel *foodName;
@end

@implementation TipsDetailsCollectionViewCell

- (void)dealloc {
    [_foodImage release];
    [_foodName release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.foodImage = [[UIImageView alloc] init];
//    _foodImage.backgroundColor = [UIColor grayColor];
    _foodImage.layer.cornerRadius = 5;
    _foodImage.layer.masksToBounds = YES;
    [self.contentView addSubview:_foodImage];
    [_foodImage release];
    
    self.foodName = [[UILabel alloc] init];
//    _foodName.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:_foodName];
    [_foodName release];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _foodImage.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 25);
    _foodName.frame = CGRectMake(0, _foodImage.frame.origin.y + _foodImage.frame.size.height + 5, self.contentView.frame.size.width, 25);
    
}

- (void)sendValueWithModel:(TipsDetailsModel *)tipsDetailsModel {
    [_foodImage sd_setImageWithURL:[NSURL URLWithString:tipsDetailsModel.imagePathThumbnails] placeholderImage:[UIImage imageNamed:@"zhanwei_02.png"]];
    _foodName.text = tipsDetailsModel.name;
}

@end
